<?php


/**
 * +-------------------------------------------------------------
 * |Caption:
 * +-------------------------------------------------------------
 * |Author: Lenny
 * +-------------------------------------------------------------
 * |Email:  1685964109@qq.com
 * +-------------------------------------------------------------
 * |Date:   2024-03-12 09:42
 * +-------------------------------------------------------------
 */

use app\service\middleware\CheckDomain;
use think\facade\Route;
use app\service\middleware\LoginLimit;
use app\service\middleware\Token;

//登录
Route::group('login', function () {
    Route::post('login', 'login/login');//登录
//    Route::post('login', 'login/login')->middleware(LoginLimit::class);//登录
    Route::get('captcha', 'login/captcha');//验证码
});

//首页
Route::group('stat', function () {
    Route::post('list', 'Stat/list');//统计
})->middleware(Token::class);

//数据看板
Route::group('board', function () {
    Route::post('warehouse_overview', 'board.index/warehouseOverview');//统计
    Route::post('warehouse_detail', 'board.index/warehouseDetail');//仓库明细
    Route::post('warehouse_warning', 'board.index/warehouseWarning');//仓库预警
    Route::post('goods_sales', 'board.index/goodsSales');//商品销售统计
    Route::post('store_detail', 'board.index/storeDetail');//门店明细
    Route::post('store_growth', 'board.index/storeGrowth');//门店增长量
    Route::post('deliver_money', 'board.index/deliverMoney');//每日配送金额统计
    Route::post('salesman_area_sales', 'board.index/salesmanAreaSales');//业务员区域销售额
    Route::post('map', 'board.index/map');//数字化地图
    Route::post('day', 'board.index/dayStat');//日统计
    Route::post('month', 'board.index/monthStat');//月统计
    Route::post('quarter', 'board.index/quarterStat');//季度统计
    Route::post('year', 'board.index/yearStat');//年统计
    Route::post('collection', 'board.index/collectionStat');//回款统计
    Route::post('collection_data', 'board.index/collectionData');//回款数据
})->middleware(Token::class);

//商品
Route::group('goods', function () {
    Route::post('list', 'Goods/list');//列表
    Route::get('modify', 'Goods/edit');//修改
    Route::post('details', 'Goods/detail');//详情
    Route::post('modify_status', 'Goods/editStatus');//修改状态
    Route::post('select', 'Goods/search');//查询商品
    Route::post('goods_rule', 'Goods/goodsRule');//查询规格
    Route::group('cate', function () {
        Route::post('list', 'GoodsCate/list');//分类列表
        Route::post('select', 'GoodsCate/search');//查询
    });
})->middleware(Token::class);


//门店
Route::group('store', function () {
    Route::post('list', 'Store/list');//列表
    Route::post('details', 'Store/detail');//详情
    Route::post('select', 'Store/search');//查询
    //门店用户
    Route::group('user', function () {
        Route::post('list', 'StoreUser/list')->append(['is_salesman' => '2']);//列表
        Route::post('create', 'StoreUser/add')->append(['is_salesman' => '2']);//添加
        Route::post('details', 'StoreUser/detail');//详情
        Route::post('select', 'StoreUser/search')->append(['is_salesman' => '2']);//查询
    });
    //门店业务员
    Route::group('sales', function () {
        Route::post('list', 'StoreUser/list')->append(['is_salesman' => '1']);//列表
        Route::post('create', 'StoreUser/add')->append(['is_salesman' => '1']);//添加
        Route::post('details', 'StoreUser/detail');//详情
        Route::post('select', 'StoreUser/search')->append(['is_salesman' => '1']);//查询
    });

    //门店预存款
    Route::group('amount', function () {
        Route::post('list', 'SupplierStoreGoodsAmount/list');
        Route::post('create', 'SupplierStoreGoodsAmount/add');
        Route::post('details', 'SupplierStoreGoodsAmount/detail');//详情
        Route::post('select',   'SupplierStoreGoodsAmount/search');
        Route::get('stop', 'SupplierStoreGoodsAmount/editStatus')->append(['status'=> 2]);//禁用
        Route::get('start', 'SupplierStoreGoodsAmount/editStatus')->append(['status'=> 1]);//启用
        Route::post('del', 'SupplierStoreGoodsAmount/del');
    });

})->middleware(Token::class);

// 仓库
Route::group('warehouse', function () {
    // 仓库列表
    Route::post('list', 'Warehouse/list');
    // 仓库商品列表
    Route::post('goods_list', 'WarehouseGoods/list');
    // 出入库列表
    Route::post('in_out_list', 'WarehouseStorageGoodsLogs/list');
})->middleware(Token::class);

// 订单
Route::group('order',function (){
   Route::post('list','Order/list');
   Route::post('detail_list','OrderDetail/list');
})->middleware(Token::class);



//上传
Route::rule('upload/:action', 'upload/:action')->middleware(CheckDomain::class); //该中间件用于检测当前域名是否合法
